home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
stats
/
xymath25.arj
/
XYMATH.DOC
< prev
next >
Wrap
Text File
|
1993-07-30
|
40KB
|
885 lines
XYmath
by Charles Taylor
PO Box 277875
Sacramento, CA 95827-7875
(C) Copyright 1989, 1991 by C. Taylor
All Rights Reserved
_______
____|__ | (R)
--| | |-------------------
| ____|__ | Association of
| | |_| Shareware
|__| o | Professionals
-----| | |---------------------
|___|___| MEMBER
page (1)
TABLE OF CONTENTS
Introduction...............................................3
The Shareware Concept......................................4
Getting Started (Backup and Installation)..................5
Applications
Plot an Equation......................................7
Integrate an Equation.................................7
Find the Maximum Value of an Equation.................8
Solve the Roots of an Equation........................8
Estimate Values Between Data Points...................9
Search Common Equation Forms for Best Fit.............9
Estimate Values Outside Data Points...................9
Perform an Exhaustive Search for Best Equation Fit...10
Change an Equation y=f(x) into x=f(y)................10
Glossary of Terms
Curve Fit............................................11
Linear Equation......................................11
Non-Linear Equation..................................11
Linear Combination of Standard Forms.................12
Exhaustive Search....................................12
Transform of X and Y / Transpose of Data.............13
Least Squares Method (Gauss' Principle)..............13
Standard Deviation...................................13
Correlation Coefficient..............................14
Spline Curve (Natural Spline)........................14
Tensioned Spline Curve (Tension Factor)..............14
Integration..........................................15
Derivative (Slope, dy/dx)............................15
Root Solving.........................................15
Minima/Maxima........................................15
Interpolate / Extrapolate............................15
DISCLAIMER - AGREEMENT
Users of XYmath must accept this disclaimer of warranty:
"XYmath is supplied as is. The author disclaims all
warranties, expressed or implied, including, without
limitation, the warranties of merchantability and of fitness
for any purpose. The author assumes no liability for damages,
direct or conse-quential, which may result from the use of
XYmath."
page (2)
Introduction:
XYmath - A SOLUTION TO MOST COMMON X,Y MATH PROBLEMS
WHICH USE AN EQUATION OF THE FORM: Y = f(X)
MAIN FEATURES:
Equations:
*Fits data to virtually any y=f(x) equation
(linear or non-linear)
*Selects best equation for data fit from thousands of
candidate equation forms
*Uses least squares methods to fit curves with minimum
total error or minimum percent error at each data point
*Key data points may be weighted to give them more or
less impact on the curve fit
*Provides correlation coefficients and standard
deviation for curve fits
*Performs a variety of spline fit options including
tensioned splines and natural cubic splines
*Takes user defined equations as input
Math Functions:
*Integrates any of the above equations over a definite
interval (selected curve fit equation, spline curve, or
user defined equation)
*Solves roots of the above equations over a
defined interval
*Calculates first derivatives of the above equations at
a point or many points over a defined interval
*Locates minimum and maximum equation values for any of
the above equations over a defined interval
*Interpolates between data points based on any of the
above equations
*Extrapolates data based on any of the above equations
Data:
*Creates data tables from any of the above equations
(y or dy/dx)
*Allows data transpositions prior to curve fitting
(eg. x=(x-1) )
*Supports data Import option to and from Lotus 123
*Supplies a Spreadsheet-like environment in which to
edit data
Environment:
*Fully menu driven, user-friendly environment
*Plots data and/or any of the above equations in linear,
logarithmic, or semi-logarithmic format with many
options to customize the display
*Supports all common graphic hardware devices
(Hercules,CGA,EGA,...)
*Makes use of floating point co-processor (if available)
*15 significant digits carried for internal calculations
page (3)
THE SHAREWARE CONCEPT:
Sharware is a DISTRIBUTION concept whereby interested users
may evaluate software at no cost. Users are able to evaluate
the software on their own system(s), in their own special work
environment, with no sales people involved. The evaluation
period will vary from software to software, however, continued
use of that code should be accompanied by payment to the
author or software development firm.
Copyright laws apply to shareware just as they do to
commercial software. The primary difference between shareware
and retail software is that with shareware you know if it's
good or bad BEFORE you pay for it.
As a software user, you benefit because you get to use the
software to determine whether it meets your needs before you
pay for it, and authors benefit because they are able to get
their products into your hands without the hundreds of
thousands of dollars in expenses it takes to launch a
traditional retail software product. There are many programs
on the market today which would never have become available
without the shareware marketing method.
The shareware system and the continued availability of quality
shareware products depend on your willingness to register and
pay for the shareware you use. It's the registration fees you
pay which allow us to support and continue to develop our
products.
Please show your support for shareware by registering those
programs you actually use and by passing them on to others.
XYmath has an authorized evaluation period of one month.
After one month of evaluation, if the code is worthy of
continued use, a registered copy of XYmath should be purchased
for $50. A check or money order should be sent to
C. Taylor
XYmath registration
PO Box 277875
Sacramento, Ca. 95827-7875
California residents should add 6.5% sales tax (total = $53.25)
XYmath should be freely given to any and all interested
parties for evaluation. Evaluation copies of the most recent
version of XYmath may be obtained at the above address for
$15. If ordered from any "Shareware Distributor", no more
than $15 should be charged for that evaluation copy.
Commercial users may purchase a site license and receive a
volume purchase discount.
page (4)
When ordering XYmath, please print and use the ordering form
found in file "INVOICE.DOC" on the shareware disk. The
information on that form will be used to create a
"registration file" which will be sent to registered users
along with the most recent version of XYmath.
Registered users are also encouraged to give copies of XYmath
to any other interested parties, however, the registration
file on their disk should NOT be given as part of the software
package. The Registration file can be deleted by the command
DEL *.REG
Any difficulties which might be encountered with XYmath or any
suggestions for improving XYmath should be directed to the
above mailing address. Although XYmath membership in the ASP
guarantees registered users three months of support, all users
are encouraged to submit their questions or comments at any
time and every reasonable effort will be made to respond.
XYmath is produced by a member of the Association of Shareware
Professionals (ASP). ASP wants to make sure that the
shareware principle works for you. If you are unable to
resolve a shareware-related problem by contacting XYmath
directly, ASP may be able to help. The ASP Ombudsman can help
you resolve a dispute or problem with an ASP member, but does
not provide technical support for members' products.
Please write to the ASP Ombudsman at:
ASP Ombudsman
545 Grover Road
Muskegon, MI 49442-9427
U.S.A.
or send a CompuServe message via CompuServe MAIL to ASP
Ombudsman 70007,3536.
GETTING STARTED:
The first thing to do with the XYmath disk is to make a backup
copy. Place the original XYmath disk in drive a: and give the
DOS command
DISKCOPY A: A:
Have a blank disk ready. When prompted to insert the target
disk, remove the original XYmath disk and put the target disk
in drive a:. It will be formatted if necessary by the
DISKCOPY command. Place the original XYmath disk in a safe
place and use the backup disk for running the code.
page (5)
If a hard drive is available, it is best to copy all files
from the floppy disk to the hard drive. If your hard drive is
drive C:, then the following DOS commands will create a
subdirectory called XYmath and copy all necessary files into it.
CD C:\
MD XYMATH
CD C:\XYMATH
COPY A:*.*
XYmath can then be executed by simply typing
XYMATH
preferably from the directory or sub-directory in which it is
installed. In the above installation example the sub-
directory XYMATH is the best execution environment. If
running from floppy disk, put the DOS prompt to that floppy
before executing XYMATH. Because the graphic device driver
files are assumed to be in the directory from which XYmath is
run, no graphic displays will be possible if the above advice
is not followed.
page (6)
APPLICATIONS:
Some typical applications for XYmath follow
A) Plot an Equation
B) Integrate an Equation
C) Find the Maximum Value of an Equation
D) Solve the Roots of an Equation
E) Estimate Values Between Data Points
F) Search Common Equation Forms for Best Fit
G) Estimate Values Outside Data Points
H) Perform an Exhaustive Search for Best Equation Fit
I) Change an Equation y=f(x) into x=f(y)
In the following Applications, Numbered items indicate Menu
Choices.
A) Plot an Equation
From the top menu choose
1)Equations
2)Input Equation
-and enter: Y = 50 + 2*x^2 -0.25*x^3
-hit <esc> to exit
3)Graphics
4)Display Plot
-the plot is displayed
-hit any key to return to top menu
-the graph may be customized under the
Graphics menu for example:
5)Graphics
6)Axes
7)X Axis Plot Range
8)Low X Value
-input: -2.0
9)Display Graph
-hit any key to return to top menu
B) Integrate an Equation
Use the equation and setup from Application A
Starting at top menu:
1)Math Operation
2)Integrate
3)Low X limit
-input: 0.0
4)Upper X limit
-input: 10.0
5)Integrate Function
-the integral = 541.667
-the analytical solution =
50x + (2/3)x^3 - (.25/4)x^4
which agrees with the above numerical result
-hit Return to see the Graph
-hit any key to return to top menu
page (7)
C) Find the Maximum Value of an Equation
Use the equation and setup from Application A
Starting at top menu:
1)Math Operation
2)Minimum/Maximum
3)Lower X Range
-enter: 0.0
4)Upper X Range
-enter: 10.0
5)Calculate Min/Max
-minimum is at upper X value (ie. a trivial
result)
-maximum is at X = 5.333
-the analytical maximum = 16/3 = 5.333
D) Solve the Roots of an Equation
Use the equation and setup from Application A
Starting at top menu:
1)Math Operation
2)Root Solve
3)Lower X Range
-enter: 0.0
4)Upper X Range
-enter: 10.0
5)Y input
-enter: 60.0
-2 roots found for Y=60 between x=0 and x=10
x=2.7639 and x=7.2361
-after first root is displayed, hit return
to see second
-hit <esc> to return to top menu
page (8)
E) Estimate Values Between Data Points
Before entering a data set, we will clear memory of
previous tasks
1)Files
2)Options
3)Reinitialize All Memory
-answer Yes to warning message
4)Data
5)Data SpreadSheet
-enter the following data set (each number
may be followed by a carriage return or an
arrow key to both move and enter data)
X Y
1 1
2 2.5
3 3.5
4 3.75
5 3.5
6 3.0
-hit <esc> to return to top menu
6)Math Operation
7)Curvefit
8)Spline Curve
9)Cubic Spline (natural)
-graph is displayed
-hit any key to return to top menu
10)Math Operation
11)Evaluate
12)X input
-enter: 1.5
program shows y=1.7573 at x=1.5
-hit <esc> to return to top menu
F) Search Common Equation Forms for Best Fit
Use the data set from Application E
From the top menu
1)Math Operation
2)Curvefit
3)Fit Curves to Common Equation Forms
4)Fit Curves Using Total Error Minimization
-results in: ln(y) = c1 + c2x + c3ln(x)
-hit any key to see graph
-hit any key to return to top menu
G) Estimate Values Outside Data Points
Use the data set from Application E
Perform Application F (search of common equation forms)
From the top menu
1)Math Operation
2)Evaluate
3)X input
-enter: 11.0
-results in: y=0.73781 at x=11.0
Use the methods of Application A to plot from x=1 to
x=12 Notice that the curve looks "REASONABLE" in
extrapolation
page (9)
Perform Application E (fit points to spline curve)
Notice that the result looks "UNREASONABLE" in
extrapolation
H) Perform an Exhaustive Search for Best Equation Fit
Use the data set from Application E
From the top menu
1)Math Operation
2)Curvefit
3)Exhaustive Search
4)Begin Curve Fit
-results in:
1/y = c1 + c2 x^2 + c3 exp(1/x)
This operation may take a few minutes to search all
the equations Systems with a math co-processor will
show much better performance
I) Change an Equation y=f(x) into x=f(y)
Before beginning, clear memory as in Application E
Given the equation y = x^2 + sin(x)/exp(x) + cos(x)^2/3 ,
our task is to find an equation for x = f(y)
1)Enter the above equation as shown in
Application A
From the top menu
first fill the data table from the equation
2)Data
3)Fill Data From Equation
4)Y vs. X
5)Lower X Value
-enter: 0.0
6)Upper X Value
-enter: 2.0
7)Increment of X
-enter: 0.1
8)Fill Data Table
-hit <esc> to return to top menu
next make the y data the independent variable
9)Data
10)Select Independent
11)y data
now fit the data with y as the independent variable
12)Math Operation
13)Curvefit
14)Fit to Common Equation Forms
15)Fit Curves Using Total Error
-results in: x = c1 + c2 (1/y)^2 + c3 ln(y)
as the best curve fit
-an exhaustive search would reveal an even
better fit
page (10)
GLOSSARY OF TERMS:
Although most of XYmath conforms to standard
mathematical nomenclature, some clarification may be required.
The following definitions will address both terms unique to
XYmath, as well as terms common to mathematics in general.
CURVE FIT
For the purposes of XYmath, curve fitting is the
process of finding the "best" equation which passes through or
near each point of a data set. Because there are an infinite
number of curves which pass through a given set of data
points, the choice of "best" curve will often be a matter of
judgement (technical, artistic, or arbitrary). It is not
uncommon to select a curve which rates lower on its
correlation coefficient simply because it is better behaved as
it goes to infinity or passes through zero. Common technical
measures of "best" curve are least squares, standard
deviation, or correlation coefficient.
LINEAR EQUATION
XYmath considers a linear equation to be one which is
linear in its real constants. Examples include:
y = c1 + c2 x
y = c1 sin(x) + c2 ln(x) + c3 x^0.5
1/ln(y) = c1 sin(1/x) + c2 cos(x^2)
because all of the constants in the above equations are in
separate terms of the equation and are not raised to any power
or operated upon by a function such as sin, exp, or ln.
Linear equations can be fitted to data directly using
matrix solution methods with a least squares criterion. These
equations are therefore the least time consuming and least
trouble to curve fit using XYmath.
NON-LINEAR EQUATION
Non-linear equations can not be fitted directly to
data using matrix methods but must use iterative approximation
methods. Such equations have real constants which are
products of each other, are exponents, or are operated upon by
functions such as sin, exp, or ln. Common equations which are
non-linear in their real constants include power curves,
exponential equations, and S-curves.
y = c1 x^c2
y = c1 exp(c2 x)
y = 1 / (c1 + c2 exp(-x))
Notice, however, that all of the above equations can be
"linearized" by appropriately taking the logarithm or inverse
of both sides. The power curve, for example can be expressed
as
ln(y) = ln(c1) + c2 ln(x)
and in this form can be directly fitted to data with matrix
methods.
page (11)
There are some subtleties in this approach of which
the reader should be aware. Fitting this "linearized" power
curve with a conventional least squares criterion will result
in a minimum percent error at each data point instead of the
expected minimum total error which is typical of the method.
There is nothing at all wrong with this difference and, in
fact, for data which spans several orders of magnitude, this
is often preferable. Because it provides a philosophically
different approach to curve fitting, it should be noted and
considered at the start of each curve fitting task.
Non-linear equations are easily fitted by XYmath but
do require an initial guess at any real constants in the
equation. Often a linearized equation solution can give
guidance in making those initial guesses.
LINEAR COMBINATION OF STANDARD FORMS
XYmath provides matrix solution methods for all
equations which are linear combinations of standard forms.
These equations are linear by the above definition, and are
constructed as the sum of standard functions of x multiplied
by real constants (the determination of the constants is the
curve fitting task). The standard forms of x are those which
appear under the "Exhaustive Search" menu option of curve
fitting in XYmath. These standard forms consist of a basic
function of x, and a transform of x. If the function of x was
1/x and the transform was x=ln(x) then the standard form would
be 1/ln(x). If the function and transform were reversed, then
the standard form would be ln(1/x).
Using this approach to defining equation forms,
thousands of linear equations can be investigated for any set
of data which needs to be fitted.
EXHAUSTIVE SEARCH
An exhaustive search in XYmath is the process by which
literally thousands of equations can be fitted to a data set
and screened for "goodness" of fit. Using the exhaustive
search definition(defined below), XYmath generates equation
forms and, using matrix solution methods, fits each one to the
data. The sum of the errors squared, or the sum of the
percent error squared is used to select the "best" curve. The
60 highest ranking equations are saved during the search and
any one of them may be selected as the "best" by the user
under the "Choose Equation" option of the "Equation" main menu
option.
EXHAUSTIVE SEARCH DEFINITION
The exhaustive search definition(ESD) tells XYmath
which functions of x, x transforms, and y transforms may be
used in constructing linear equation candidates for a curve
fitting task. The ESD also defines the minimum and maximum
number of terms which can occur in the equation as well as the
"best" fit selection criterion (total or percent error). The
ESD may be read from a disk file or defined manually during an
exhaustive search. Several ESDs are provided with XYmath to
select such common searches as straight lines, quadratic
equations, cubics, hyperbolas, etc.
page (12)
TRANSFORM OF X AND Y / TRANSPOSE OF DATA
The term transform will be distinguished from the term
transpose within XYmath to identify two similar operations.
Transforms are the operations performed upon x or y for each
"individual term" of an equation of linear combination of
standard forms. A different transform may be applied to each
term of that equation. A transpose of data changes the data
set itself. Any and all curve fitting, graphing, etc. is done
with the transposed data and NOT the original data.
It is often the case that curve fitting a given
equation directly yields poor results, whereas fitting a
"transformed" equation works very well. For example fitting a
line (y = c1 + c2 x) to data may be unsatisfactory when the
equation (1/y = c1 + c2 x) may give extremely good results.
The difference between the two equations is the transformation
of y to 1/y.
It is also common to transpose data from its raw form
into one more suitable or more convenient. For example some
temperature data may exist in units of degrees Fahrenheit when
degrees Kelvin may be required. Under such conditions the
data should be transposed as (x = (x + 459.67) / 1.8).
The available transforms are controlled by the user
when the exhaustive search definition is selected. Data
transpose equations may be input by the user within the data
spreadsheet or under the "Data" option of the main menu. Both
the raw data and the transposed data are displayed in the data
spreadsheet.
LEAST SQUARES METHOD (Gauss' Principle)
In the least squares curve fitting method, the curve
fit's error at each data point is squared and the sum of those
squared errors is minimized to give the "best" fit. In other
words, the method finds the unique constants in a linear
equation which minimizes the sum of the square of the
difference between the curve's prediction of y at each x data
value and the y data itself.
There are statistical reasons for using the least
squares method. If the y values follow a normal distribution
(bell-shaped curve), then the resulting curve can be shown to
be the most probable solution. The "linear regression" is the
most common application of this method.
STANDARD DEVIATION
The standard deviation represents the total variation
in the data which is not accounted for by the fitted equation.
Data, for example, which follows a basically linear trend may
have "noise" in it about the fitted line. That variation
about the line is described by its standard deviation.
Approximately 95% of the equation's prediction errors will lie
within 2 standard deviations of the curve (assuming a normal
distribution for that error).
page (13)
Any noise about the equation prediction will usually
be rendered meaningless if the number of terms in the equation
is the same as the number of data points. This is because an
equation can usually be forced through each data point when
the number of terms and data points are equal. Any errors are
therefore hidden through the use of too many constants in the
equation (ie. the more complex equation does not show the
"true" character of the x,y relationship).
CORRELATION COEFFICIENT
The correlation coefficient represents the fraction of
the total variation in the data which is accounted for by the
fitted equation. A value of 1.0 is the most desirable, 0.0 is
the least desirable.
Correlation coefficients are intended to be guides as
to how applicable an equation form is to a data set. It is
possible, however, that choosing an equation with a lower
correlation coefficient may be a better choice for a given
application due to other characteristics of the equations (eg.
behavior at infinity or unwanted inflection points).
A perfect correlation coefficient can usually be
obtained if the number of terms in the equation is set equal
to the number of data points. This can be a misleading result
and should therefore be viewed with caution.
SPLINE CURVE (Natural Spline)
A natural spline curve passes through each point of a
data set and has a "natural" smooth curvature. The name
derives from a draftsman's tool, a spline, which is a flexible
strip that can be held by weights so that it passes through
each desired point on the draftsman's table. A mathematical
procedure is used to mimic these laws of beam flexure which
the draftsman employs.
A requirement of spline curves is that each data point
be "single valued". If there is more than one y value at a
given x value, then XYmath will give the option of using the
minimum, maximum, or average value of the multiple y data
points for creating a spline.
TENSIONED SPLINE CURVE (TENSION FACTOR)
A natural spline curve can sometimes give a curve
shape which is unsatisfactory. Typically the undesirable
features involve exaggerated transitions from one point to
another. This problem can often be solved by placing the
curve under "tension". The tension factor is used to express
the fraction of the spline which is like a straight line,
point-to-point curve verses a natural spline. A tension
factor of zero, for example, is exactly equivalent to a
natural spline. A factor of 1.0 is a straight line from point
to point.
page (14)
INTEGRATION
Integration is the finding of the area underneath a
curve. There are many numerical methods available to perform
this calculation. The method used by XYmath is the Simpson
1/3 rule. It involves breaking the total area up into many
small sections and summing the estimated areas of each section
in order to approximate the total area under the curve.
The equation to be integrated can be 1) input
directly, or 2) the result of a curve fitting operation.
DERIVATIVE (slope, dy/dx)
The first derivative of a curve is equal to the slope
of that curve. XYmath calculates the slope of the curve at a
given point or for many points over a range of x values. It
is therefore possible to create graphs and/or data tables of y
vs. x, as well as dy/dx vs. x.
The equation to be operated upon can be 1) input
directly, or 2) the result of a curve fitting operation.
ROOT SOLVING
Given an equation y=f(x), it is often required to know
the value of x for which y has some desired value. This is
called root solving. XYmath will search a given interval of x
for the value of y desired and will display all roots found.
The equation may be 1) input directly, or 2) the
result of a curve fitting operation.
MINIMA/MAXIMA
Finding the x value for which y is a minimum or
maximum is a very common problem with an equation y=f(x).
XYmath will find both the maximum and minimum over a given
interval of x. Some care should be used when performing this
task since "local optima" can sometimes be found instead of
the real optimum. Examining a plot of the equation and doing
min/max searches in small sub-regions can sometimes yield more
accurate results when the equation is very complicated (many
inflection and zero derivative points).
As with the above operations, the equation may be 1)
input directly, or 2) the result of a curve fitting operation.
INTERPOLATE/EXTRAPOLATE
Evaluating a fitted equation between data points or
outside of data points is probably the most common reason to
fit data. Interpolating between points usually gives a higher
confidence answer than extrapolating outside of the data
points. Interpolation is well performed by spline curves and,
in general, is the best approach to take. Extrapolation can
be very dangerous with spline curves(splines often turn
pathological outside their applicable data range) and
therefore splines are not usually recommended for
extrapolation.
For any evaluation of an equation, it is highly
recommended that a graph of the data and equation be viewed.
In general, when predicting values by fitted equation, THERE
IS NO SINGLE CORRECT ANSWER. Always look at the graph to
insure that the predicted value is "reasonable".
page (15)